/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package berkeley.lab5;

/**
 *
 * @author u
 */
public class Test {
    
    public static void main(String args[]) {
        X[] xa = new X[5];
        for (int i = 0; i < xa.length; i++) {
            xa[i] = new X(i);
        }
        
        Y[] ya = new Y[5];
        for (int i = 0; i < ya.length; i++) {
            ya[i] = new Y(i);
            System.out.println(X.constant); // Part 3
        }
        
        /**
         * Part 1
         */
        // Compile time
        xa = ya;
        // Run-time
        X[] ta = new Y[5];
        xa = (Y[])ta;
        ta = xa;
        
        /**
         * Part 4
         */
        X x4 = new Y(10);
        //((X)x4).f();
        
        X x42 = new Y(20);
        //((Y)x42).f();
        
        try {
            x42.getClass().getSuperclass().getMethod("f").invoke(x42);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
